<?php
namespace action\traits;
class Del extends Base{
    
    function main(){
        $id = I()->getInt('id', 0);
        if(!$id){
            $this->redirect($this->urldo('index'));
        }
        $model = $this->getModel();
        $cond = [
            'id' => $id
        ];
        if(($model->count($cond) == 1) && $model->delete($cond)){
            $id = 0;
        }
        $this->redirect($this->urldo('index', $id));
    }

}